home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / obero / OberonAModules.lha / XpkMaster.mod < prev    next >
Text File  |  1999-02-26  |  16KB  |  397 lines

  1. (*************************************************************************
  2.  
  3. :Program.    XpkMaster.mod
  4. :Contents.   Interface-Module for xpkmaster.library
  5. :Author.     Hartmut Goebel [hG]
  6. :Copyright.  Copyright © 1991 by Hartmut Goebel
  7. :Copyright.  May be free dirstibuted with the Xpk-Package
  8. :Copyright.  permission is given to be inlcuded with AmigaOberon
  9. :Language.   Oberon
  10. :Translator. Amiga Oberon V2.14
  11. :History.    V0.9, 08 Jan 1992 Hartmut Goebel [hG]
  12. :History.    V1.0, 04 Jun 1992 [hG]
  13. :History.    V1.1, 06 Jul 1992 [hG] remove "Xpk" from procname, because
  14. :History.          in Oberon you U must import qualified, so this is useless
  15. :History.    V1.1b 27 Jul 1992 [hG] XpkMasterNA build in
  16. :History.    V2.0  04 Aug 1992 [hG] adapted to Xpk 2.0
  17. :Date.       04 Aug 1992 01:25:20
  18.  
  19. :Remark.     compile with "set NoAssert" to generate XpkMasterNA, which
  20. :Remark.     does not asure the lib is opened successfull (you must check
  21. :Remark.     this by yourself then!)
  22.  
  23.  
  24. Changed by Morten Bjergstrøm to work with Oberon-A (It didn't before)
  25. Now your program won't quit if xpkmaster.library isn't available therefore
  26. you have to check xpk.base before you use any xpk functions!
  27. EMail: mbjergstroem@hotmail.com
  28. *************************************************************************)
  29.  
  30.  
  31. <*STANDARD-*>
  32. MODULE [2] XpkMaster;
  33.  
  34.  
  35. IMPORT
  36.   e := Exec,
  37.   I := Intuition,
  38.   s := SYSTEM,
  39.   u := Utility,
  40.   Kernel;
  41.  
  42. CONST
  43.  
  44.   XpkName = "xpkmaster.library";
  45.  
  46. (*****************************************************************************
  47.  *
  48.  *
  49.  *      The packing/unpacking tags
  50.  *
  51.  *)
  52.  
  53. (* Tags we support *)
  54.   tagBase       * = u.user + ORD("X")*256 + ORD("P");
  55.  
  56. (* Caller must supply ONE of these to tell Xpk#?ackFile where to get data from *)
  57.   inName        * = tagBase+01H; (* Process an entire named file *)
  58.   inFH          * = tagBase+02H; (* File handle - start from current position *)
  59.                                  (* If packing partial file, must also supply InLen *)
  60.   inBuf         * = tagBase+03H; (* Single unblocked memory buffer *)
  61.                                  (* Must also supply InLen *)
  62.   inHook        * = tagBase+04H; (* Call custom Hook to read data *)
  63.                                  (* If packing, must also supply InLen *)
  64.                                  (* If unpacking, InLen required only for PPDecrunch *)
  65.  
  66. (* Caller must supply ONE of these to tell Xpk#?ackFile where to send data to *)
  67.   outName       * = tagBase+10H; (* Write (or overwrite) this data file *)
  68.   outFH         * = tagBase+11H; (* File handle - write from current position on *)
  69.   outBuf        * = tagBase+12H; (* Unblocked buffer - must also supply OutBufLen *)
  70.   getOutBuf     * = tagBase+13H; (* Master allocates OutBuf - ti_Data points to buf ptr *)
  71.   outHook       * = tagBase+14H; (* Callback Hook to get output buffers *)
  72.  
  73. (* Other tags for Pack/Unpack *)
  74.   inLen         * = tagBase+20H; (* Length of data in input buffer *)
  75.   outBufLen     * = tagBase+21H; (* Length of output buffer *)
  76.   getOutLen     * = tagBase+22H; (* ti_Data points to long to receive OutLen *)
  77.   getOutBufLen  * = tagBase+23H; (* ti_Data points to long to receive OutBufLen *)
  78.   password      * = tagBase+24H; (* Password for de/encoding *)
  79.   getError      * = tagBase+25H; (* ti_Data points to buffer for error message *)
  80.   outMemType    * = tagBase+26H; (* Memory type for output buffer *)
  81.   passThru      * = tagBase+27H; (* Bool: Pass through unrecognized formats on unpack *)
  82.   stepDown      * = tagBase+28H; (* Bool: Step down pack method if necessary *)
  83.   chunkHook     * = tagBase+29H; (* Call this Hook between chunks *)
  84.   packMethod    * = tagBase+2AH; (* Do a FindMethod before packing *)
  85.   chunkSize     * = tagBase+2BH; (* Chunk size to try to pack with *)
  86.   packMode      * = tagBase+2CH; (* Packing mode for sublib to use *)
  87.   noClobber     * = tagBase+2DH; (* Don't overwrite existing files  *)
  88.   ignore        * = tagBase+2EH; (* Skip this tag                   *)
  89.   taskPri       * = tagBase+2FH; (* Change priority for (un)packing *)
  90.   fileName      * = tagBase+30H; (* File name for progress report   *)
  91.   shortError    * = tagBase+31H; (* Output short error messages     *)
  92.   packersQuery  * = tagBase+32H; (* Query available packers         *)
  93.   packerQuery   * = tagBase+33H; (* Query properties of a packer    *)
  94.   modeQuery     * = tagBase+34H; (* Query properties of packmode    *)
  95.   lossyOK       * = tagBase+35H; (* Lossy packing permitted? def.=no*)
  96.  
  97.   findMethod    * = packMethod;  (* Compatibility *)
  98.  
  99.   margin        * = 256;         (* Safety margin for output buffer      *)
  100.  
  101.  
  102. TYPE
  103. (*****************************************************************************
  104.  *
  105.  *
  106.  *     The hook function interface
  107.  *
  108.  *)
  109.  
  110. (* Message passed to InHook and OutHook as the ParamPacket *)
  111.   XpkIOMsgPtr * = POINTER TO XpkIOMsg;
  112.   XpkIOMsg * = RECORD
  113.     type     * : LONGINT;   (* Read/Write/Alloc/Free/Abort        *)
  114.     ptr      * : e.APTR;    (* The mem area to read from/write to *)
  115.     size     * : LONGINT;   (* The size of the read/write         *)
  116.     ioError  * : LONGINT;   (* The IoErr() that occurred          *)
  117.     reserved * : e.ADDRESS; (* Reserved for future use            *)
  118.     private1 * : e.ADDRESS; (* Hook specific, will be set to 0 by *)
  119.     private2 * : e.ADDRESS; (* master library before first use    *)
  120.     private3 * : e.ADDRESS;
  121.     private4 * : e.ADDRESS;
  122.   END;
  123.  
  124. CONST
  125. (* The values for XpkIoMsg.type *)
  126.   ioRead    * = 1;
  127.   ioWrite   * = 2;
  128.   ioFree    * = 3;
  129.   ioAbort   * = 4;
  130.   ioGetBuf  * = 5;
  131.   ioSeek    * = 6;
  132.   ioTotSize * = 7;
  133.  
  134.  
  135. (*****************************************************************************
  136.  *
  137.  *
  138.  *      The progress report interface
  139.  *
  140.  *)
  141.  
  142. TYPE
  143. (* Passed to ChunkHook as the ParamPacket *)
  144.   XpkProgressPtr * = POINTER TO XpkProgress;
  145.   XpkProgress * = RECORD
  146.     type           * : LONGINT;  (* Type of report: start/cont/end/abort       *)
  147.     packerName     * : e.STRPTR; (* Brief name of packer being used            *)
  148.     packerLongName * : e.STRPTR; (* Descriptive name of packer being used      *)
  149.     activity * : e.STRPTR;       (* Packing/unpacking message                  *)
  150.     fileName * : e.STRPTR;       (* Name of file being processed, if available *)
  151.     cCur  * : LONGINT;           (* Amount of packed data already processed    *)
  152.     uCur  * : LONGINT;           (* Amount of unpacked data already processed  *)
  153.     uLen  * : LONGINT;           (* Amount of unpacked data already processed  *)
  154.     cf    * : LONGINT;           (* Compression factor so far                  *)
  155.     done  * : LONGINT;           (* Percentage done already                    *)
  156.     speed * : LONGINT;           (* Bytes per second, from beginning of stream *)
  157.     reserved * : ARRAY 8 OF e.ADDRESS; (* For future use               *)
  158.   END;
  159.  
  160. CONST
  161. (* The values for XpkProgress.type *)
  162.   progStart * = 1;
  163.   progMid   * = 2;
  164.   progEnd   * = 3;
  165.  
  166. (*****************************************************************************
  167.  *
  168.  *
  169.  *       The file info block
  170.  *
  171.  *)
  172.  
  173. TYPE
  174.   XpkFibPtr * = POINTER TO XpkFib;
  175.   XpkFib * = RECORD
  176.     type * : LONGINT                 ; (* Unpacked, packed, archive?   *)
  177.     uLen * : LONGINT                 ; (* Uncompressed length          *)
  178.     cLen * : LONGINT                 ; (* Compressed length            *)
  179.     nLen * : LONGINT                 ; (* Next chunk len               *)
  180.     uCur * : LONGINT                 ; (* Uncompressed bytes so far    *)
  181.     cCur * : LONGINT                 ; (* Compressed bytes so far      *)
  182.     id     * : ARRAY 4 OF s.BYTE       ; (* 4 letter ID of packer        *)
  183.     packer * : ARRAY 6 OF s.BYTE       ; (* 4 letter name of packer      *)
  184.     subVersion * : INTEGER           ; (* Required sublib version      *)
  185.     masVersion * : INTEGER           ; (* Required masterlib version   *)
  186.     flags * : SET                ; (* Password?                    *)
  187.     head * : ARRAY 16 OF s.BYTE        ; (* First 16 bytes of orig. file *)
  188.     ratio * : LONGINT                ; (* Compression ratio            *)
  189.     reserved * : ARRAY 8 OF e.ADDRESS; (* For future use               *)
  190.   END;
  191.  
  192.   XpkFH * = POINTER TO RECORD
  193.     fib*: XpkFib
  194.     (